home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 July: Mac OS SDK / Dev.CD Jul 00 SDK2.toast / Development Kits / Cross Platform / QuickTime 4.1.2 Windows SDK / CIncludes / PictUtils.h < prev    next >
Encoding:
C/C++ Source or Header  |  2000-04-12  |  11.4 KB  |  277 lines  |  [TEXT/R*ch]

  1. /*
  2.      File:        PictUtils.h
  3.  
  4.      Contains:    Picture Utilities Interfaces.
  5.  
  6.      Version:    Technology:    Mac OS 8.5
  7.                  Release:    QuickTime 4.1
  8.  
  9.      Copyright:    (c) 1990-1999 by Apple Computer, Inc., all rights reserved
  10.  
  11.      Bugs?:        For bug reports, consult the following page on
  12.                  the World Wide Web:
  13.  
  14.                      http://developer.apple.com/bugreporter/
  15.  
  16. */
  17. #ifndef __PICTUTILS__
  18. #define __PICTUTILS__
  19.  
  20. #ifndef __MACTYPES__
  21.     #include <MacTypes.h>
  22. #endif
  23.  
  24. #ifndef __PALETTES__
  25.     #include <Palettes.h>
  26. #endif
  27.  
  28.  
  29.  
  30.  
  31. #if PRAGMA_ONCE
  32. #pragma once
  33. #endif
  34.  
  35. #ifdef __cplusplus
  36. extern "C" {
  37. #endif
  38.  
  39. #if PRAGMA_IMPORT
  40. #pragma import on
  41. #endif
  42.  
  43. #if PRAGMA_STRUCT_ALIGN
  44.     #pragma options align=mac68k
  45. #elif PRAGMA_STRUCT_PACKPUSH
  46.     #pragma pack(push, 2)
  47. #elif PRAGMA_STRUCT_PACK
  48.     #pragma pack(2)
  49. #endif
  50.  
  51. /* verbs for the GetPictInfo, GetPixMapInfo, and NewPictInfo calls */
  52. enum {
  53.     returnColorTable            = 0x0001,
  54.     returnPalette                = 0x0002,
  55.     recordComments                = 0x0004,
  56.     recordFontInfo                = 0x0008,
  57.     suppressBlackAndWhite        = 0x0010
  58. };
  59.  
  60. enum {
  61.                                                                 /* color pick methods */
  62.     systemMethod                = 0,                            /* system color pick method */
  63.     popularMethod                = 1,                            /* method that chooses the most popular set of colors */
  64.     medianMethod                = 2                                /* method that chooses a good average mix of colors */
  65. };
  66.  
  67. enum {
  68.                                                                 /* color bank types */
  69.     ColorBankIsCustom            = -1,
  70.     ColorBankIsExactAnd555        = 0,
  71.     ColorBankIs555                = 1
  72. };
  73.  
  74. typedef long                             PictInfoID;
  75.  
  76. struct CommentSpec {
  77.     short                             count;                        /* number of occurrances of this comment ID */
  78.     short                             ID;                            /* ID for the comment in the picture */
  79. };
  80. typedef struct CommentSpec                CommentSpec;
  81. typedef CommentSpec *                    CommentSpecPtr;
  82. typedef CommentSpecPtr *                CommentSpecHandle;
  83.  
  84. struct FontSpec {
  85.     short                             pictFontID;                    /* ID of the font in the picture */
  86.     short                             sysFontID;                    /* ID of the same font in the current system file */
  87.     long                             size[4];                    /* bit array of all the sizes found (1..127) (bit 0 means > 127) */
  88.     short                             style;                        /* combined style of all occurrances of the font */
  89.     long                             nameOffset;                    /* offset into the fontNamesHdl handle for the font's name */
  90. };
  91. typedef struct FontSpec                    FontSpec;
  92. typedef FontSpec *                        FontSpecPtr;
  93. typedef FontSpecPtr *                    FontSpecHandle;
  94.  
  95. struct PictInfo {
  96.     short                             version;                    /* this is always zero, for now */
  97.     long                             uniqueColors;                /* the number of actual colors in the picture(s)/pixmap(s) */
  98.     PaletteHandle                     thePalette;                    /* handle to the palette information */
  99.     CTabHandle                         theColorTable;                /* handle to the color table */
  100.     Fixed                             hRes;                        /* maximum horizontal resolution for all the pixmaps */
  101.     Fixed                             vRes;                        /* maximum vertical resolution for all the pixmaps */
  102.     short                             depth;                        /* maximum depth for all the pixmaps (in the picture) */
  103.     Rect                             sourceRect;                    /* the picture frame rectangle (this contains the entire picture) */
  104.     long                             textCount;                    /* total number of text strings in the picture */
  105.     long                             lineCount;                    /* total number of lines in the picture */
  106.     long                             rectCount;                    /* total number of rectangles in the picture */
  107.     long                             rRectCount;                    /* total number of round rectangles in the picture */
  108.     long                             ovalCount;                    /* total number of ovals in the picture */
  109.     long                             arcCount;                    /* total number of arcs in the picture */
  110.     long                             polyCount;                    /* total number of polygons in the picture */
  111.     long                             regionCount;                /* total number of regions in the picture */
  112.     long                             bitMapCount;                /* total number of bitmaps in the picture */
  113.     long                             pixMapCount;                /* total number of pixmaps in the picture */
  114.     long                             commentCount;                /* total number of comments in the picture */
  115.     long                             uniqueComments;                /* the number of unique comments in the picture */
  116.     CommentSpecHandle                 commentHandle;                /* handle to all the comment information */
  117.     long                             uniqueFonts;                /* the number of unique fonts in the picture */
  118.     FontSpecHandle                     fontHandle;                    /* handle to the FontSpec information */
  119.     Handle                             fontNamesHandle;            /* handle to the font names */
  120.     long                             reserved1;
  121.     long                             reserved2;
  122. };
  123. typedef struct PictInfo                    PictInfo;
  124. typedef PictInfo *                        PictInfoPtr;
  125. typedef PictInfoPtr *                    PictInfoHandle;
  126. typedef CALLBACK_API( OSErr , InitPickMethodProcPtr )(SInt16 colorsRequested, UInt32 *dataRef, SInt16 *colorBankType);
  127. typedef CALLBACK_API( OSErr , RecordColorsProcPtr )(UInt32 dataRef, RGBColor *colorsArray, SInt32 colorCount, SInt32 *uniqueColors);
  128. typedef CALLBACK_API( OSErr , CalcColorTableProcPtr )(UInt32 dataRef, SInt16 colorsRequested, void *colorBankPtr, CSpecArray resultPtr);
  129. typedef CALLBACK_API( OSErr , DisposeColorPickMethodProcPtr )(UInt32 dataRef);
  130. typedef STACK_UPP_TYPE(InitPickMethodProcPtr)                     InitPickMethodUPP;
  131. typedef STACK_UPP_TYPE(RecordColorsProcPtr)                     RecordColorsUPP;
  132. typedef STACK_UPP_TYPE(CalcColorTableProcPtr)                     CalcColorTableUPP;
  133. typedef STACK_UPP_TYPE(DisposeColorPickMethodProcPtr)             DisposeColorPickMethodUPP;
  134. #if OPAQUE_UPP_TYPES
  135.     EXTERN_API(InitPickMethodUPP)
  136.     NewInitPickMethodUPP           (InitPickMethodProcPtr    userRoutine);
  137.  
  138.     EXTERN_API(RecordColorsUPP)
  139.     NewRecordColorsUPP               (RecordColorsProcPtr        userRoutine);
  140.  
  141.     EXTERN_API(CalcColorTableUPP)
  142.     NewCalcColorTableUPP           (CalcColorTableProcPtr    userRoutine);
  143.  
  144.     EXTERN_API(DisposeColorPickMethodUPP)
  145.     NewDisposeColorPickMethodUPP    (DisposeColorPickMethodProcPtr userRoutine);
  146.  
  147.     EXTERN_API(void)
  148.     DisposeInitPickMethodUPP       (InitPickMethodUPP        userUPP);
  149.  
  150.     EXTERN_API(void)
  151.     DisposeRecordColorsUPP           (RecordColorsUPP            userUPP);
  152.  
  153.     EXTERN_API(void)
  154.     DisposeCalcColorTableUPP       (CalcColorTableUPP        userUPP);
  155.  
  156.     EXTERN_API(void)
  157.     DisposeDisposeColorPickMethodUPP    (DisposeColorPickMethodUPP userUPP);
  158.  
  159.     EXTERN_API(OSErr)
  160.     InvokeInitPickMethodUPP           (SInt16                    colorsRequested,
  161.                                     UInt32 *                dataRef,
  162.                                     SInt16 *                colorBankType,
  163.                                     InitPickMethodUPP        userUPP);
  164.  
  165.     EXTERN_API(OSErr)
  166.     InvokeRecordColorsUPP           (UInt32                    dataRef,
  167.                                     RGBColor *                colorsArray,
  168.                                     SInt32                    colorCount,
  169.                                     SInt32 *                uniqueColors,
  170.                                     RecordColorsUPP            userUPP);
  171.  
  172.     EXTERN_API(OSErr)
  173.     InvokeCalcColorTableUPP           (UInt32                    dataRef,
  174.                                     SInt16                    colorsRequested,
  175.                                     void *                    colorBankPtr,
  176.                                     CSpecArray                resultPtr,
  177.                                     CalcColorTableUPP        userUPP);
  178.  
  179.     EXTERN_API(OSErr)
  180.     InvokeDisposeColorPickMethodUPP    (UInt32                dataRef,
  181.                                     DisposeColorPickMethodUPP userUPP);
  182.  
  183. #else
  184.     enum { uppInitPickMethodProcInfo = 0x00000FA0 };                 /* pascal 2_bytes Func(2_bytes, 4_bytes, 4_bytes) */
  185.     enum { uppRecordColorsProcInfo = 0x00003FE0 };                     /* pascal 2_bytes Func(4_bytes, 4_bytes, 4_bytes, 4_bytes) */
  186.     enum { uppCalcColorTableProcInfo = 0x00003EE0 };                 /* pascal 2_bytes Func(4_bytes, 2_bytes, 4_bytes, 4_bytes) */
  187.     enum { uppDisposeColorPickMethodProcInfo = 0x000000E0 };         /* pascal 2_bytes Func(4_bytes) */
  188.     #define NewInitPickMethodUPP(userRoutine)                         (InitPickMethodUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppInitPickMethodProcInfo, GetCurrentArchitecture())
  189.     #define NewRecordColorsUPP(userRoutine)                         (RecordColorsUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppRecordColorsProcInfo, GetCurrentArchitecture())
  190.     #define NewCalcColorTableUPP(userRoutine)                         (CalcColorTableUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppCalcColorTableProcInfo, GetCurrentArchitecture())
  191.     #define NewDisposeColorPickMethodUPP(userRoutine)                 (DisposeColorPickMethodUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppDisposeColorPickMethodProcInfo, GetCurrentArchitecture())
  192.     #define DisposeInitPickMethodUPP(userUPP)                         DisposeRoutineDescriptor(userUPP)
  193.     #define DisposeRecordColorsUPP(userUPP)                         DisposeRoutineDescriptor(userUPP)
  194.     #define DisposeCalcColorTableUPP(userUPP)                         DisposeRoutineDescriptor(userUPP)
  195.     #define DisposeDisposeColorPickMethodUPP(userUPP)                 DisposeRoutineDescriptor(userUPP)
  196.     #define InvokeInitPickMethodUPP(colorsRequested, dataRef, colorBankType, userUPP)  (OSErr)CALL_THREE_PARAMETER_UPP((userUPP), uppInitPickMethodProcInfo, (colorsRequested), (dataRef), (colorBankType))
  197.     #define InvokeRecordColorsUPP(dataRef, colorsArray, colorCount, uniqueColors, userUPP)  (OSErr)CALL_FOUR_PARAMETER_UPP((userUPP), uppRecordColorsProcInfo, (dataRef), (colorsArray), (colorCount), (uniqueColors))
  198.     #define InvokeCalcColorTableUPP(dataRef, colorsRequested, colorBankPtr, resultPtr, userUPP)  (OSErr)CALL_FOUR_PARAMETER_UPP((userUPP), uppCalcColorTableProcInfo, (dataRef), (colorsRequested), (colorBankPtr), (resultPtr))
  199.     #define InvokeDisposeColorPickMethodUPP(dataRef, userUPP)         (OSErr)CALL_ONE_PARAMETER_UPP((userUPP), uppDisposeColorPickMethodProcInfo, (dataRef))
  200. #endif
  201. /* support for pre-Carbon UPP routines: NewXXXProc and CallXXXProc */
  202. #define NewInitPickMethodProc(userRoutine)                         NewInitPickMethodUPP(userRoutine)
  203. #define NewRecordColorsProc(userRoutine)                         NewRecordColorsUPP(userRoutine)
  204. #define NewCalcColorTableProc(userRoutine)                         NewCalcColorTableUPP(userRoutine)
  205. #define NewDisposeColorPickMethodProc(userRoutine)                 NewDisposeColorPickMethodUPP(userRoutine)
  206. #define CallInitPickMethodProc(userRoutine, colorsRequested, dataRef, colorBankType) InvokeInitPickMethodUPP(colorsRequested, dataRef, colorBankType, userRoutine)
  207. #define CallRecordColorsProc(userRoutine, dataRef, colorsArray, colorCount, uniqueColors) InvokeRecordColorsUPP(dataRef, colorsArray, colorCount, uniqueColors, userRoutine)
  208. #define CallCalcColorTableProc(userRoutine, dataRef, colorsRequested, colorBankPtr, resultPtr) InvokeCalcColorTableUPP(dataRef, colorsRequested, colorBankPtr, resultPtr, userRoutine)
  209. #define CallDisposeColorPickMethodProc(userRoutine, dataRef)    InvokeDisposeColorPickMethodUPP(dataRef, userRoutine)
  210. EXTERN_API( OSErr )
  211. GetPictInfo                        (PicHandle                 thePictHandle,
  212.                                  PictInfo *                thePictInfo,
  213.                                  short                     verb,
  214.                                  short                     colorsRequested,
  215.                                  short                     colorPickMethod,
  216.                                  short                     version)                            THREEWORDINLINE(0x303C, 0x0800, 0xA831);
  217.  
  218. EXTERN_API( OSErr )
  219. GetPixMapInfo                    (PixMapHandle             thePixMapHandle,
  220.                                  PictInfo *                thePictInfo,
  221.                                  short                     verb,
  222.                                  short                     colorsRequested,
  223.                                  short                     colorPickMethod,
  224.                                  short                     version)                            THREEWORDINLINE(0x303C, 0x0801, 0xA831);
  225.  
  226. EXTERN_API( OSErr )
  227. NewPictInfo                        (PictInfoID *            thePictInfoID,
  228.                                  short                     verb,
  229.                                  short                     colorsRequested,
  230.                                  short                     colorPickMethod,
  231.                                  short                     version)                            THREEWORDINLINE(0x303C, 0x0602, 0xA831);
  232.  
  233. EXTERN_API( OSErr )
  234. RecordPictInfo                    (PictInfoID             thePictInfoID,
  235.                                  PicHandle                 thePictHandle)                        THREEWORDINLINE(0x303C, 0x0403, 0xA831);
  236.  
  237. EXTERN_API( OSErr )
  238. RecordPixMapInfo                (PictInfoID             thePictInfoID,
  239.                                  PixMapHandle             thePixMapHandle)                    THREEWORDINLINE(0x303C, 0x0404, 0xA831);
  240.  
  241. EXTERN_API( OSErr )
  242. RetrievePictInfo                (PictInfoID             thePictInfoID,
  243.                                  PictInfo *                thePictInfo,
  244.                                  short                     colorsRequested)                    THREEWORDINLINE(0x303C, 0x0505, 0xA831);
  245.  
  246. EXTERN_API( OSErr )
  247. DisposePictInfo                    (PictInfoID             thePictInfoID)                        THREEWORDINLINE(0x303C, 0x0206, 0xA831);
  248.  
  249. #if OLDROUTINENAMES
  250. #define DisposPictInfo(thePictInfoID) DisposePictInfo(thePictInfoID)
  251. #endif  /* OLDROUTINENAMES */
  252.  
  253.  
  254.  
  255.  
  256.  
  257. #if PRAGMA_STRUCT_ALIGN
  258.     #pragma options align=reset
  259. #elif PRAGMA_STRUCT_PACKPUSH
  260.     #pragma pack(pop)
  261. #elif PRAGMA_STRUCT_PACK
  262.     #pragma pack()
  263. #endif
  264.  
  265. #ifdef PRAGMA_IMPORT_OFF
  266. #pragma import off
  267. #elif PRAGMA_IMPORT
  268. #pragma import reset
  269. #endif
  270.  
  271. #ifdef __cplusplus
  272. }
  273. #endif
  274.  
  275. #endif /* __PICTUTILS__ */
  276.  
  277.